package com.example.service.impl;


import com.example.service.FileService;
import com.example.utils.MyAliYunOssUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 创建者： 智晟全哥
 */
// 使用阿里云的方式完成文件上传
@Service
@Primary
public class FileServiceImpl2 implements FileService {
    @Autowired
    private MyAliYunOssUtils myAliYunOssUtils;
    @Override
    public String saveFile(MultipartFile file) throws IOException {
        /*
           面向工具,调用工具的方法将 file 对象保存到阿里云的oss即可
         */
        String s = myAliYunOssUtils.uploadToOss(file);
        return s;
    }
}
